//
//  CHBaseViewController.m
//  SZTZ
//
//  Created by 陈浩 on 2017/3/6.
//  Copyright © 2017年 陈浩. All rights reserved.
//

#import "CHBaseViewController.h"
#import "CHItemButton.h"


@interface CHBaseViewController ()<UIWebViewDelegate>

@end

@implementation CHBaseViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
   
//    
//    
//    self.itemBtn = [[CHItemButton alloc] initWithFrame:CGRectMake(0, 0, 100, 40)];
//    self.itemBtn.titleLabel.font = [UIFont systemFontOfSize:14];
//    [self.itemBtn setImage:[UIImage imageNamed:@"pull"] forState:UIControlStateNormal];
////    [self.itemBtn setTitle:@"2017年12月" forState:UIControlStateNormal];
//    [self.itemBtn addTarget:self action:@selector(rightBtnClick) forControlEvents:UIControlEventTouchUpInside];
//    
//    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:self.itemBtn];;
    
    [self setupUI];
   
}


- (void)setupUI {
    _webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, UIScreenW, UIScreenH- 64)];
    _webView.delegate = self;
    _webView.backgroundColor = [UIColor whiteColor];
    
    _progressLayer = [WYWebProgressLayer new];
    _progressLayer.frame = CGRectMake(0, 42, SCREEN_WIDTH, 2);
    
    [self.navigationController.navigationBar.layer addSublayer:_progressLayer];
    [self.view addSubview:_webView];
}



-(void)showNotice{
    
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, UIScreenW, 40)];
    label.text = @"暂无数据";
    label.textAlignment = NSTextAlignmentCenter;
    label.textColor = [UIColor lightGrayColor];
    label.font = [UIFont systemFontOfSize:14];
    label.center = CGPointMake(self.view.center.x, self.view.center.y - 64);
    [self.view addSubview:label];
    
}







#pragma mark - UIWebViewDelegate
- (void)webViewDidStartLoad:(UIWebView *)webView {
    [_progressLayer startLoad];
}

- (void)webViewDidFinishLoad:(UIWebView *)webView {
    [_progressLayer finishedLoad];
    
}

- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {
    [_progressLayer finishedLoad];
}

- (void)dealloc {
    
    [_progressLayer closeTimer];
    [_progressLayer removeFromSuperlayer];
    _progressLayer = nil;
    NSLog(@"i am dealloc");
}




@end
